//
//  WriteOrderCtrl.m
//  demo
//
//  Created by bruce on 17/9/16.
//  Copyright © 2017年 com.uc. All rights reserved.
//

#import "WriteOrderViewController.h"
#import <Masonry/Masonry.h>
#import "UIColor+Extension.h"

@interface WriteOrderViewController ()

@property(nonatomic, retain)UIScrollView *scollView;

@property(nonatomic, retain)UIView *viewAddr;
@property(nonatomic, retain)UILabel *lblName;
@property(nonatomic, retain)UILabel *lblPhone;
@property(nonatomic, retain)UILabel *lblAddr;
@property(nonatomic, retain)UIImageView *ivPic;
@property(nonatomic, retain)UILabel *lblTitle;
@property(nonatomic, retain)UILabel *lbldes;
@property(nonatomic, retain)UILabel *lblOrigPrice;
@property(nonatomic, retain)UILabel *lblDisPrice;
@property(nonatomic, retain)UILabel *lblProductNum;
@property(nonatomic, retain)UILabel *lblShareNum;
@property(nonatomic, retain)UILabel *lblCoupon;//优惠劵
@property(nonatomic, retain)UILabel *lblDeduction;//积分抵扣
@property(nonatomic, retain)UIButton *btnDeduction;//
@property(nonatomic, retain)UIButton *btnExpress;//在线快递
@property(nonatomic, retain)UIButton *btnSince;//线下自提

@property(nonatomic, retain)UILabel *lblProTotalPriceSub;//商品总价
@property(nonatomic, retain)UILabel *lblfreightSub;//运费
@property(nonatomic, retain)UILabel *lblDiscountSub;//优惠
@property(nonatomic, retain)UILabel *lblDeductionSub;//积分抵扣

@property(nonatomic, retain)UILabel *lblSubTotal;//小计

@property(nonatomic, retain)UIButton *btnWxPay;
@property(nonatomic, retain)UIButton *btnAlipay;
@property(nonatomic, retain)UIButton *btnQQPay;

@property(nonatomic, retain)UILabel *lblSendInfo;//配送信息

@end

@implementation WriteOrderViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    [self initView];
    
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationItem.title = @"填写订单";
    [self defaultMessageRightButton];
    
}

- (void)initView{
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    self.scollView = [[UIScrollView alloc] init];
    self.scollView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.scollView];
    [self.scollView mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(self.view);
        make.left.right.bottom.equalTo(self.view);
    }];
    
    // 设置scrollView的子视图，即过渡视图contentSize，并设置其约束
    UIView *containerView = [[UIView alloc]init];
    [self.scollView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.and.right.equalTo(self.scollView).with.insets(UIEdgeInsetsZero);
        make.width.equalTo(self.scollView);
    }];
    
    
    
    UIImageView *ivTop = [[UIImageView alloc] init];
    [ivTop setImage:[UIImage imageNamed:@"postion"]];
    [containerView addSubview:ivTop];
    [ivTop mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(containerView.mas_top);
        make.width.mas_equalTo(containerView.mas_width);
        make.height.mas_equalTo(10);
        
    }];
    
    self.viewAddr = [[UIView alloc] init];
    [containerView addSubview:self.viewAddr];
    [self.viewAddr mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(ivTop.mas_bottom);
        make.width.mas_equalTo(containerView.mas_width);
        make.height.mas_equalTo(95);
        
    }];
    
    self.lblName = [[UILabel alloc] init];
    self.lblName.text = @"张三";
    self.lblName.font = [UIFont systemFontOfSize:16];
    self.lblName.textColor = RGBA(51, 51, 51, 1);
    [self.viewAddr addSubview:self.lblName];
    [self.lblName mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.viewAddr.mas_left).offset(22);
         make.top.equalTo(self.viewAddr.mas_top).offset(20);
     }];
    
    self.lblPhone = [[UILabel alloc] init];
    self.lblPhone.text = @"18888888888";
    self.lblPhone.font = [UIFont systemFontOfSize:16];
    self.lblPhone.textColor = RGBA(51, 51, 51, 1);
    [self.viewAddr addSubview:self.lblPhone];
    [self.lblPhone mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(self.viewAddr.mas_right).offset(-45);
         make.top.equalTo(self.viewAddr.mas_top).offset(20);
     }];

    
    
    self.lblAddr = [[UILabel alloc] init];
    self.lblAddr.text = @"福州省 福州市 鼓楼区 温泉支路 851大楼 福州省 福州市 鼓楼区 温泉支路 851大楼 （350000）";
    self.lblAddr.font = [UIFont systemFontOfSize:14];
    self.lblAddr.textColor = RGBA(102, 102, 102, 1);
    self.lblAddr.numberOfLines = 2;
    [self.viewAddr addSubview:self.lblAddr];
    [self.lblAddr mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.viewAddr.mas_left).offset(22);
         make.top.equalTo(self.lblName.mas_bottom).offset(10);
         make.right.equalTo(self.viewAddr.mas_right).offset(-45);
     }];
    
    UIImageView *ivAddrMore = [[UIImageView alloc] init];
    [ivAddrMore setImage:[UIImage imageNamed:@"more3"]];
    [self.viewAddr addSubview:ivAddrMore];
    [ivAddrMore mas_makeConstraints:^(MASConstraintMaker *make){
        make.size.mas_equalTo(CGSizeMake(7, 13));
        make.top.equalTo(self.viewAddr.mas_top).offset(45);
        make.right.equalTo(self.viewAddr.mas_right).offset(-13);
        
        
        
    }];
    
    
    UIView *lineAddr = [[UIView alloc] init];
    lineAddr.backgroundColor = [UIColor colorWithHexString:@"EFEFEF"];
    [containerView addSubview:lineAddr];
    [lineAddr  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(self.viewAddr.mas_bottom);
        make.width.mas_equalTo(containerView.mas_width);
        make.height.mas_equalTo(10);
    }];
   
    
    self.ivPic = [[UIImageView alloc] init];
    [self.ivPic setBackgroundColor:[UIColor colorWithHexString:@"f8f8f8"]];
    [self.ivPic setImage:[UIImage imageNamed:@"image"]];
    [self.ivPic setContentMode:UIViewContentModeScaleAspectFit];
    [containerView addSubview:self.ivPic];
    [self.ivPic mas_makeConstraints:^(MASConstraintMaker *make){

        make.left.equalTo(containerView.mas_left).offset(22);
        make.top.equalTo(lineAddr.mas_bottom).offset(15);
        make.size.mas_equalTo(CGSizeMake(110, 110));
        
        
        
    }];
    
    self.lblTitle = [[UILabel alloc] init];
    self.lblTitle.text = @"商品标题";
    self.lblTitle.font = [UIFont systemFontOfSize:14];
    self.lblTitle.textColor = RGBA(51, 51, 51, 1);
    [containerView addSubview:self.lblTitle];
    [self.lblTitle mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.ivPic.mas_right).offset(10);
         make.top.equalTo(lineAddr.mas_bottom).offset(15);
     }];

    self.lbldes = [[UILabel alloc] init];
    self.lbldes.text = @"商品描述商品描述商品描述商品描述商品描述商品描述商品描述商品描述商品描述商品描述";
    self.lbldes.font = [UIFont systemFontOfSize:12];
    self.lbldes.textColor = RGBA(153, 153, 153, 1);
    self.lbldes.numberOfLines = 2;
    [containerView addSubview:self.lbldes];
    [self.lbldes mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.ivPic.mas_right).offset(10);
         make.top.equalTo(self.lblTitle.mas_bottom).offset(15);
         make.right.equalTo(containerView.mas_right).offset(-40);
     }];

    self.lblDisPrice = [[UILabel alloc] init];
    self.lblDisPrice.text = @"¥499";
    self.lblDisPrice.font = [UIFont systemFontOfSize:14];
    self.lblDisPrice.textColor = RGBA(248, 146, 0, 1);
    [containerView addSubview:self.lblDisPrice];
    [self.lblDisPrice mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.ivPic.mas_right).offset(10);
         make.top.equalTo(self.lbldes.mas_bottom).offset(35);
     }];

    self.lblOrigPrice = [[UILabel alloc] init];
    self.lblOrigPrice.text = @"价格¥699";
    self.lblOrigPrice.font = [UIFont systemFontOfSize:10];
    self.lblOrigPrice.textColor = RGBA(153, 153, 153, 1);
    [containerView addSubview:self.lblOrigPrice];
    [self.lblOrigPrice mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.lblDisPrice.mas_right).offset(10);
         make.top.equalTo(self.lbldes.mas_bottom).offset(38);
     }];

    
    self.lblProductNum = [[UILabel alloc] init];
    self.lblProductNum.text = @"X1";
    self.lblProductNum.font = [UIFont systemFontOfSize:14];
    self.lblProductNum.textColor = RGBA(153, 153, 153, 1);
    [containerView addSubview:self.lblProductNum];
    [self.lblProductNum mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(containerView.mas_right).offset(-20);
         make.top.equalTo(self.lbldes.mas_bottom).offset(36);
     }];
    
    
    UIView *lineProduct = [[UIView alloc] init];
    lineProduct.backgroundColor = [UIColor colorWithHexString:@"DDDDDD"];
    [containerView addSubview:lineProduct];
    [lineProduct  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(self.ivPic.mas_bottom).offset(15);
        make.width.mas_equalTo(containerView.mas_width);
        make.height.mas_equalTo(1);
    }];
    
    
    //===================所得分享值====================
    
    UIView * viewShare = [[UIView alloc] init];
    [containerView addSubview:viewShare];
    [viewShare mas_makeConstraints:^(MASConstraintMaker *make)
     {
        make.top.equalTo(lineProduct.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UILabel *lblShareTitle = [[UILabel alloc] init];
    lblShareTitle.text = @"所得分享值";
    lblShareTitle.font = [UIFont systemFontOfSize:16];
    lblShareTitle.textColor = RGBA(51, 51, 51, 1);
    [viewShare addSubview:lblShareTitle];
    [lblShareTitle mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewShare.mas_left).offset(22);
         make.centerY.equalTo(viewShare.mas_centerY);
     }];
    
    self.lblShareNum = [[UILabel alloc] init];
    self.lblShareNum.text = @"240";
    self.lblShareNum.font = [UIFont systemFontOfSize:14];
    self.lblShareNum.textColor = RGBA(102, 102, 102, 1);
    [viewShare addSubview:self.lblShareNum];
    [self.lblShareNum mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewShare.mas_right).offset(-20);
         make.centerY.equalTo(viewShare.mas_centerY);
     }];


    
    
    UIView *lineShare = [[UIView alloc] init];
    lineShare.backgroundColor = [UIColor colorWithHexString:@"DDDDDD"];
    [containerView addSubview:lineShare];
    [lineShare  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(viewShare.mas_bottom);
        make.left.equalTo(containerView.mas_left).offset(12);
        make.right.equalTo(containerView.mas_right).offset(-12);
        make.height.mas_equalTo(1);
    }];
    
    
    //===================优惠劵====================
    
    UIView * viewCoupon = [[UIView alloc] init];
    [containerView addSubview:viewCoupon];
    [viewCoupon mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(lineShare.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UILabel *lblCoupon = [[UILabel alloc] init];
    lblCoupon.text = @"优惠劵";
    lblCoupon.font = [UIFont systemFontOfSize:16];
    lblCoupon.textColor = RGBA(51, 51, 51, 1);
    [viewCoupon addSubview:lblCoupon];
    [lblCoupon mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewCoupon.mas_left).offset(22);
         make.centerY.equalTo(viewCoupon.mas_centerY);
     }];
    
    self.lblCoupon = [[UILabel alloc] init];
    self.lblCoupon.text = @"使用30元优惠劵";
    self.lblCoupon.font = [UIFont systemFontOfSize:14];
    self.lblCoupon.textColor = RGBA(248, 146, 0, 1);
    [viewCoupon addSubview:self.lblCoupon];
    [self.lblCoupon mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewCoupon.mas_right).offset(-12);
         make.centerY.equalTo(viewCoupon.mas_centerY);
     }];
    
    
    
    
    UIView *lineCoupon = [[UIView alloc] init];
    lineCoupon.backgroundColor = [UIColor colorWithHexString:@"DDDDDD"];
    [containerView addSubview:lineCoupon];
    [lineCoupon  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(viewCoupon.mas_bottom);
        make.left.equalTo(containerView.mas_left).offset(12);
        make.right.equalTo(containerView.mas_right).offset(-12);
        make.height.mas_equalTo(1);
    }];
    
    
    //===================积分抵扣====================
    
    UIView * viewDeduction = [[UIView alloc] init];
    [containerView addSubview:viewDeduction];
    [viewDeduction mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(lineCoupon.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UILabel *lblDeduction = [[UILabel alloc] init];
    lblDeduction.text = @"积分抵扣";
    lblDeduction.font = [UIFont systemFontOfSize:16];
    lblDeduction.textColor = RGBA(51, 51, 51, 1);
    [viewDeduction addSubview:lblDeduction];
    [lblDeduction mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewDeduction.mas_left).offset(22);
         make.centerY.equalTo(viewDeduction.mas_centerY);
     }];
    
    self.lblDeduction = [[UILabel alloc] init];
    self.lblDeduction.text = @"-¥20";
    self.lblDeduction.font = [UIFont systemFontOfSize:14];
    self.lblDeduction.textColor = RGBA(248, 146, 0, 1);
    [viewDeduction addSubview:self.lblDeduction];
    [self.lblDeduction mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(lblDeduction.mas_right).offset(10);
         make.centerY.equalTo(viewDeduction.mas_centerY);
     }];
    
    
    self.btnDeduction = [[UIButton alloc] init];
    
    [containerView addSubview:self.btnDeduction];
    [self.btnDeduction setBackgroundImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
    [self.btnDeduction  setSelected:YES];
    [self.btnDeduction addTarget:self action:@selector(checkBoxClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btnDeduction mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(viewDeduction.mas_right).offset(-12);
        make.centerY.equalTo(viewDeduction.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        
        
        
    }];
    
    
    
    UIView *lineDeduction = [[UIView alloc] init];
    lineDeduction.backgroundColor = [UIColor colorWithHexString:@"DDDDDD"];
    [containerView addSubview:lineDeduction];
    [lineDeduction  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(viewDeduction.mas_bottom);
        make.left.equalTo(containerView.mas_left).offset(12);
        make.right.equalTo(containerView.mas_right).offset(-12);
        make.height.mas_equalTo(1);
    }];
    
    //===================配送方式====================
    
    UIView * viewSendWay = [[UIView alloc] init];
    [containerView addSubview:viewSendWay];
    [viewSendWay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(lineDeduction.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UILabel *lblSendWay = [[UILabel alloc] init];
    lblSendWay.text = @"配送方式";
    lblSendWay.font = [UIFont systemFontOfSize:16];
    lblSendWay.textColor = RGBA(51, 51, 51, 1);
    [viewSendWay addSubview:lblSendWay];
    [lblSendWay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewSendWay.mas_left).offset(22);
         make.centerY.equalTo(viewSendWay.mas_centerY);
     }];
    
    
    
    
    UILabel *lblSince = [[UILabel alloc] init];
    lblSince.text = @"线下自提";
    lblSince.font = [UIFont systemFontOfSize:14];
    lblSince.textColor = RGBA(102, 102, 102, 1);
    [viewSendWay addSubview:lblSince];
    [lblSince mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewSendWay.mas_right).offset(-12);
         make.centerY.equalTo(viewSendWay.mas_centerY);
     }];
    
    self.btnSince = [[UIButton alloc] init];
    [containerView addSubview:self.btnSince];
    [self.btnSince setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
    [self.btnSince  setSelected:NO];
    [self.btnSince addTarget:self action:@selector(checkBoxClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btnSince mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(lblSince.mas_left).offset(-10);
        make.centerY.equalTo(viewSendWay.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        
    }];
    
    
    UILabel *lblExpress = [[UILabel alloc] init];
    lblExpress.text = @"在线快递";
    lblExpress.font = [UIFont systemFontOfSize:14];
    lblExpress.textColor = RGBA(102, 102, 102, 1);
    [viewSendWay addSubview:lblExpress];
    [lblExpress mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(self.btnSince.mas_left).offset(-40);
         make.centerY.equalTo(viewSendWay.mas_centerY);
     }];
    
    self.btnExpress = [[UIButton alloc] init];
    [containerView addSubview:self.btnExpress];
    [self.btnExpress setBackgroundImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
    [self.btnExpress  setSelected:YES];
    [self.btnExpress addTarget:self action:@selector(checkBoxClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btnExpress mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(lblExpress.mas_left).offset(-10);
        make.centerY.equalTo(viewSendWay.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        
    }];


    
    
    
    UIView *lineSendWay = [[UIView alloc] init];
    lineSendWay.backgroundColor = [UIColor colorWithHexString:@"EFEFEF"];
    [containerView addSubview:lineSendWay];
    [lineSendWay  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(viewSendWay.mas_bottom);
        make.width.equalTo(containerView.mas_width);
        make.height.mas_equalTo(10);
    }];


    
    //===================商品总价====================
    
    UIView * viewProductPrice = [[UIView alloc] init];
    [containerView addSubview:viewProductPrice];
    [viewProductPrice mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(lineSendWay.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(35);
     }];
    
    UILabel *lblProductPrice = [[UILabel alloc] init];
    lblProductPrice.text = @"商品总价";
    lblProductPrice.font = [UIFont systemFontOfSize:16];
    lblProductPrice.textColor = RGBA(51, 51, 51, 1);
    [viewProductPrice addSubview:lblProductPrice];
    [lblProductPrice mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewProductPrice.mas_left).offset(22);
         make.centerY.equalTo(viewProductPrice.mas_centerY);
     }];
    
    self.lblProTotalPriceSub = [[UILabel alloc] init];
    self.lblProTotalPriceSub.text = @"$499.00";
    self.lblProTotalPriceSub.font = [UIFont systemFontOfSize:14];
    self.lblProTotalPriceSub.textColor = RGBA(248, 146, 0, 1);
    [viewProductPrice addSubview:self.lblProTotalPriceSub];
    [self.lblProTotalPriceSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewProductPrice.mas_right).offset(-12);
         make.centerY.equalTo(viewProductPrice.mas_centerY);
     }];
    
    
    //===================运费====================
    
    UIView * viewSendSub = [[UIView alloc] init];
    [containerView addSubview:viewSendSub];
    [viewSendSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewProductPrice.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(35);
     }];
    
    UILabel *lblfreight = [[UILabel alloc] init];
    lblfreight.text = @"运费";
    lblfreight.font = [UIFont systemFontOfSize:16];
    lblfreight.textColor = RGBA(51, 51, 51, 1);
    [viewSendSub addSubview:lblfreight];
    [lblfreight mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewSendSub.mas_left).offset(22);
         make.centerY.equalTo(viewSendSub.mas_centerY);
     }];
    
    self.lblfreightSub = [[UILabel alloc] init];
    self.lblfreightSub.text = @"$0.00";
    self.lblfreightSub.font = [UIFont systemFontOfSize:14];
    self.lblfreightSub.textColor = RGBA(248, 146, 0, 1);
    [viewSendSub addSubview:self.lblfreightSub];
    [self.lblfreightSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewSendSub.mas_right).offset(-12);
         make.centerY.equalTo(viewSendSub.mas_centerY);
     }];

    //===================优惠====================
    
    UIView * viewDisSub = [[UIView alloc] init];
    [containerView addSubview:viewDisSub];
    [viewDisSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewSendSub.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(35);
     }];
    
    UILabel *lblDis = [[UILabel alloc] init];
    lblDis.text = @"优惠";
    lblDis.font = [UIFont systemFontOfSize:16];
    lblDis.textColor = RGBA(51, 51, 51, 1);
    [viewDisSub addSubview:lblDis];
    [lblDis mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewDisSub.mas_left).offset(22);
         make.centerY.equalTo(viewDisSub.mas_centerY);
     }];
    
    self.lblDiscountSub = [[UILabel alloc] init];
    self.lblDiscountSub.text = @"-¥0.00";
    self.lblDiscountSub.font = [UIFont systemFontOfSize:14];
    self.lblDiscountSub.textColor = RGBA(248, 146, 0, 1);
    [viewDisSub addSubview:self.lblDiscountSub];
    [self.lblDiscountSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewDisSub.mas_right).offset(-12);
         make.centerY.equalTo(viewDisSub.mas_centerY);
     }];

    
    //===================积分抵扣====================
    
    UIView * viewDeduSub = [[UIView alloc] init];
    [containerView addSubview:viewDeduSub];
    [viewDeduSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewDisSub.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(35);
     }];
    
    UILabel *lblDeDuSub = [[UILabel alloc] init];
    lblDeDuSub.text = @"积分抵扣";
    lblDeDuSub.font = [UIFont systemFontOfSize:16];
    lblDeDuSub.textColor = RGBA(51, 51, 51, 1);
    [viewDeduSub addSubview:lblDeDuSub];
    [lblDeDuSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewDeduSub.mas_left).offset(22);
         make.centerY.equalTo(viewDeduSub.mas_centerY);
     }];
    
    self.lblDeductionSub = [[UILabel alloc] init];
    self.lblDeductionSub.text = @"-¥0.00";
    self.lblDeductionSub.font = [UIFont systemFontOfSize:14];
    self.lblDeductionSub.textColor = RGBA(248, 146, 0, 1);
    [viewDeduSub addSubview:self.lblDeductionSub];
    [self.lblDeductionSub mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(viewDeduSub.mas_right).offset(-12);
         make.centerY.equalTo(viewDeduSub.mas_centerY);
     }];

    
    
    
    
    UIView *lineSub = [[UIView alloc] init];
    lineSub.backgroundColor = [UIColor colorWithHexString:@"DDDDDD"];
    [containerView addSubview:lineSub];
    [lineSub  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(viewDeduSub.mas_bottom);
        make.left.equalTo(containerView.mas_left).offset(12);
        make.right.equalTo(containerView.mas_right).offset(-12);
        make.height.mas_equalTo(1);
    }];

    
    self.lblSubTotal = [[UILabel alloc] init];
    self.lblSubTotal.text = @"共1件商品，小计：¥499.00";
    self.lblSubTotal.font = [UIFont systemFontOfSize:16];
    self.lblSubTotal.textColor = RGBA(248, 146, 0, 1);
    [viewDisSub addSubview:self.lblSubTotal];
    [self.lblSubTotal mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.equalTo(containerView.mas_right).offset(-12);
         make.top.equalTo(lineSub.mas_bottom).offset(15);
     }];
    
    
    UIView *lineSubTotal = [[UIView alloc] init];
    lineSubTotal.backgroundColor = [UIColor colorWithHexString:@"EFEFEF"];
    [containerView addSubview:lineSubTotal];
    [lineSubTotal  mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(self.lblSubTotal.mas_bottom).offset(15);
        make.width.equalTo(containerView.mas_width);
        make.height.mas_equalTo(10);
    }];

    
    //===================微信支付====================
    
    UIView * viewWx = [[UIView alloc] init];
    [containerView addSubview:viewWx];
    [viewWx mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(lineSubTotal.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UIImageView *imgWx = [[UIImageView alloc] init];
    [imgWx setImage:[UIImage imageNamed:@"weixin2"]];
    [imgWx setContentMode:UIViewContentModeScaleAspectFit];
    [viewWx addSubview:imgWx];
    [imgWx mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewWx.mas_left).offset(22);
         make.centerY.equalTo(viewWx.mas_centerY);
         make.size.mas_equalTo(CGSizeMake(30, 30));
     }];
    
    UILabel * lblWx = [[UILabel alloc] init];
    lblWx.text = @"微信支付";
    lblWx.font = [UIFont systemFontOfSize:16];
    lblWx.textColor = RGBA(51, 51, 51, 1);
    [viewWx addSubview:lblWx];
    [lblWx mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(imgWx.mas_right).offset(15);
         make.centerY.equalTo(viewWx.mas_centerY);
     }];
    
    
    self.btnWxPay = [[UIButton alloc] init];
    
    [containerView addSubview:self.btnWxPay];
    [self.btnWxPay setBackgroundImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
    [self.btnWxPay  setSelected:YES];
    [self.btnWxPay addTarget:self action:@selector(checkBoxClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btnWxPay mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(viewWx.mas_right).offset(-12);
        make.centerY.equalTo(viewWx.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));

    }];
    
    //===================支付宝支付====================
    
    UIView * viewAlipay = [[UIView alloc] init];
    [containerView addSubview:viewAlipay];
    [viewAlipay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewWx.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UIImageView *imgAlipay = [[UIImageView alloc] init];
    [imgAlipay setImage:[UIImage imageNamed:@"zhifubao"]];
    [imgAlipay setContentMode:UIViewContentModeScaleAspectFit];
    [viewAlipay addSubview:imgAlipay];
    [imgAlipay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewAlipay.mas_left).offset(22);
         make.centerY.equalTo(viewAlipay.mas_centerY);
         make.size.mas_equalTo(CGSizeMake(30, 30));
     }];
    
    UILabel * lblAlipay = [[UILabel alloc] init];
    lblAlipay.text = @"支付宝支付";
    lblAlipay.font = [UIFont systemFontOfSize:16];
    lblAlipay.textColor = RGBA(51, 51, 51, 1);
    [viewAlipay addSubview:lblAlipay];
    [lblAlipay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(imgAlipay.mas_right).offset(15);
         make.centerY.equalTo(viewAlipay.mas_centerY);
     }];
    
    
    self.btnAlipay = [[UIButton alloc] init];
    
    [containerView addSubview:self.btnAlipay];
    [self.btnAlipay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
    [self.btnAlipay  setSelected:NO];
    [self.btnAlipay addTarget:self action:@selector(checkBoxClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btnAlipay mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(viewAlipay.mas_right).offset(-12);
        make.centerY.equalTo(viewAlipay.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        
    }];
    
    //===================QQ钱包支付====================
    
    UIView * viewQQPay = [[UIView alloc] init];
    [containerView addSubview:viewQQPay];
    [viewQQPay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewAlipay.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
    UIImageView *imgQQ = [[UIImageView alloc] init];
    [imgQQ setImage:[UIImage imageNamed:@"qq"]];
    [imgQQ setContentMode:UIViewContentModeScaleAspectFit];
    [viewQQPay addSubview:imgQQ];
    [imgQQ mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewQQPay.mas_left).offset(22);
         make.centerY.equalTo(viewQQPay.mas_centerY);
         make.size.mas_equalTo(CGSizeMake(30, 30));
     }];
    
    UILabel * lblQQ = [[UILabel alloc] init];
    lblQQ.text = @"QQ钱包支付";
    lblQQ.font = [UIFont systemFontOfSize:16];
    lblQQ.textColor = RGBA(51, 51, 51, 1);
    [viewQQPay addSubview:lblQQ];
    [lblQQ mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(imgQQ.mas_right).offset(15);
         make.centerY.equalTo(viewQQPay.mas_centerY);
     }];
    
    
    self.btnQQPay = [[UIButton alloc] init];
    
    [viewQQPay addSubview:self.btnQQPay];
    [self.btnQQPay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
    [self.btnQQPay  setSelected:NO];
    [self.btnQQPay addTarget:self action:@selector(checkBoxClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.btnQQPay mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(viewQQPay.mas_right).offset(-12);
        make.centerY.equalTo(viewQQPay.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        
    }];

    
    //===================其他支付====================
    
    UIView * viewOtherPay = [[UIView alloc] init];
    [containerView addSubview:viewOtherPay];
    [viewOtherPay mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewQQPay.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(45);
     }];
    
       
    UILabel * lblOther = [[UILabel alloc] init];
    lblOther.text = @"其他支付方式";
    lblOther.font = [UIFont systemFontOfSize:16];
    lblOther.textColor = RGBA(51, 51, 51, 1);
    [viewOtherPay addSubview:lblOther];
    [lblOther mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewOtherPay.mas_left).offset(22);
         make.centerY.equalTo(viewOtherPay.mas_centerY);
     }];
    
    
    UIButton *btnMorePay = [[UIButton alloc] init];
    
    [viewOtherPay addSubview:btnMorePay];
    [btnMorePay setBackgroundImage:[UIImage imageNamed:@"more3"] forState:UIControlStateNormal];
    [btnMorePay mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.right.equalTo(viewOtherPay.mas_right).offset(-12);
        make.centerY.equalTo(viewOtherPay.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(7, 13));
        
    }];
    
    
    //===================配送信息====================
    
    UIView * viewSendInfo = [[UIView alloc] init];
    viewSendInfo.backgroundColor = [UIColor colorWithHexString:@"ffffe0"];
    [containerView addSubview:viewSendInfo];
    [viewSendInfo mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewQQPay.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(30);
     }];
    
    
    self.lblSendInfo = [[UILabel alloc] init];
    self.lblSendInfo.text = @"配送至：福建省 福州市 鼓楼区 温泉支路 851大楼";
    self.lblSendInfo.font = [UIFont systemFontOfSize:12];
    self.lblSendInfo.textColor = RGBA(153, 153, 153, 1);
    [viewSendInfo addSubview:self.lblSendInfo];
    [self.lblSendInfo mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewSendInfo.mas_left).offset(22);
         make.centerY.equalTo(viewSendInfo.mas_centerY);
     }];
    
    //===================合计／下单====================
    
    UIView * viewBuy = [[UIView alloc] init];
    [containerView addSubview:viewBuy];
    [viewBuy mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(viewSendInfo.mas_bottom);
         make.width.equalTo(containerView.mas_width);
         make.height.mas_equalTo(50);
     }];
    
    
    self.lblSendInfo = [[UILabel alloc] init];
    self.lblSendInfo.text = @"合计：499.00";
    self.lblSendInfo.font = [UIFont systemFontOfSize:16];
    self.lblSendInfo.textColor = RGBA(248, 146, 0, 1);
    [viewBuy addSubview:self.lblSendInfo];
    [self.lblSendInfo mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(viewBuy.mas_left).offset(22);
         make.centerY.equalTo(viewBuy.mas_centerY);
     }];

    
    UIButton * btnBuy = [[UIButton alloc] init];
//    [btnBuy setBackgroundImage:getImageByName(@"btn_long_common_bg") forState:UIControlStateNormal];
    btnBuy.backgroundColor = RGBA(248, 146, 0, 1);
    [btnBuy setTitle:@"下单" forState:UIControlStateNormal];
    [btnBuy setTitleColor:[UIColor colorWithHexString:@"FFFFFF"] forState:UIControlStateNormal];
    btnBuy.titleLabel.font = [UIFont systemFontOfSize:18];
    [btnBuy addTarget:self action:@selector(buyClick) forControlEvents:UIControlEventTouchUpInside];
    [viewBuy addSubview:btnBuy];
    [btnBuy mas_makeConstraints:^(MASConstraintMaker *make){
        make.centerY.equalTo(viewBuy.mas_centerY);
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(100);
        make.right.mas_equalTo(self.view.mas_right);
        
        
    }];




    // 设置过渡视图的底边距（此设置将影响到scrollView的contentSize）
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(viewBuy.mas_bottom);
    }];
    
}


- (void)checkBoxClick:(UIButton *)btn{
    [btn setSelected: !btn.isSelected];
    if (btn.isSelected) {
        [btn setBackgroundImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
        
        //快递选择互斥
        if (btn == self.btnSince) {
            [self.btnExpress setSelected:NO];
            [self.btnExpress setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
        }
        if (btn == self.btnExpress) {
            [self.btnSince setSelected:NO];
            [self.btnSince setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
        }
        
        //支付选择互斥
        if (btn == self.btnWxPay) {
            [self.btnAlipay setSelected:NO];
            [self.btnAlipay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
            
            [self.btnQQPay setSelected:NO];
            [self.btnQQPay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];

        }
        if (btn == self.btnAlipay) {
            [self.btnWxPay setSelected:NO];
            [self.btnWxPay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
            
            [self.btnQQPay setSelected:NO];
            [self.btnQQPay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
            
        }
        if (btn == self.btnQQPay) {
            [self.btnWxPay setSelected:NO];
            [self.btnWxPay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
            
            [self.btnAlipay setSelected:NO];
            [self.btnAlipay setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
            
        }
        
        
    }else{
        [btn setBackgroundImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
        
        //快递选择互斥
        if (btn == self.btnSince) {
            [self.btnExpress setSelected:YES];
            [self.btnExpress setBackgroundImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
        }
        if (btn == self.btnExpress) {
            [self.btnSince setSelected:YES];
            [self.btnSince setBackgroundImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
        }
        
        
        
    }
    
    //积分抵扣隐藏
    if (btn == self.btnDeduction) {
        [self.lblDeduction setHidden: !btn.isSelected];

    }
    
    
}

- (void)buyClick
{
}


@end
